package leetcode_1001_1100;

import java.util.LinkedList;
import java.util.List;

public class LeeCode_1003 {
    public static void main(String[] args) {
        System.out.println(isValid("abcabcababcc"));
        System.out.println(isValid("abca"));
    }
    private static boolean isValid(String s) {
        StringBuilder sb = new StringBuilder();
        for (int i = 0; i < s.length(); i++) {
            sb.append(s.charAt(i));
            if (sb.length() >= 3 && sb.substring(sb.length() - 3, sb.length()).equals("abc")){
                sb.delete(sb.length() - 3, sb.length());
            }
        }
        return sb.length() == 0;
    }
}
